/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * Author: zhnb
 * Date: 2011-7-29 下午03:31:46
 */
package com.number.operator;

import java.io.Serializable;

import com.number.bond.ObjectFactory4Bond;

import Ice.ObjectAdapter;

public class SendObjectAsParamServer implements Serializable {

    private static final long serialVersionUID = 4905376480813159331L;

    public static void main(String[] args) {

        // 0, 声明执行状态
        int status = 0;
        Ice.Communicator ic = null;

        try {

            // 1, 初始化环境
            // 加载属性文件
            ic = Ice.Util.initialize();

            // 添加自定义类
            Ice.ObjectFactory factory = new ObjectFactory4Bond();
            ic.addObjectFactory(factory, com.number.bond.BondI.ice_staticId());
            
            // 2, 初始化Adapter

            String name = "SendObjectAsParamServer";
            String endpoints = "default -h 127.0.0.1 -p 9999";
            ObjectAdapter objAdapter = ic.createObjectAdapterWithEndpoints(
                    name, endpoints);

            // 3, 创建伺服者
            Ice.Object servant = new SendObjectAsParamI();

            // 4, 添加伺服者至适配器
            objAdapter.add(servant, Ice.Util.stringToIdentity("SendObjectAsParamUID"));

            // 5, 激活
            objAdapter.activate();

System.out.println("<<SendObjectAsParamUID started>>");
            // 6, 等待关闭
            ic.waitForShutdown();

        } catch (Exception e) {
            e.printStackTrace();
            status = 1;
        } finally {
            if (ic != null) {
                ic.destroy();
            }
            System.exit(status);
        }

    }
}
